from . import app
import json


def product_worker(queue, data, producer=None):

    # data = json.dumps(data)

    with app.producer_or_acquire(producer) as producer:
        producer.publish(
            data,
            serializer='json',
            exchange=queue.exchange,
            routing_key=queue.routing_key,
            declare=[queue],
            retry=True,
        )

